package com.bmob.lover.ui.fragment.album

import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.qmuiteam.qmui.util.QMUIStatusBarHelper
import com.theone.common.ext.getColor
import com.theone.common.ext.setMargin
import com.bmob.lover.R
import com.bmob.lover.data.model.bean.Album
import com.bmob.lover.ui.adapter.AlbumAdapter
import com.bmob.lover.ui.fragment.base.BaseSwipePagerFragment
import com.bmob.lover.viewmodel.AlbumViewModel
import com.qmuiteam.qmui.widget.QMUITopBarLayout
import com.theone.mvvm.core.data.enum.LayoutManagerType

//  ┏┓　　　┏┓
//┏┛┻━━━┛┻┓
//┃　　　　　　　┃
//┃　　　━　　　┃
//┃　┳┛　┗┳　┃
//┃　　　　　　　┃
//┃　　　┻　　　┃
//┃　　　　　　　┃
//┗━┓　　　┏━┛
//    ┃　　　┃                  神兽保佑
//    ┃　　　┃                  永无BUG！
//    ┃　　　┗━━━┓
//    ┃　　　　　　　┣┓
//    ┃　　　　　　　┏┛
//    ┗┓┓┏━┳┓┏┛
//      ┃┫┫　┃┫┫
//      ┗┻┛　┗┻┛
/**
 * @author The one
 * @date 2021-04-23 10:58
 * @describe TODO
 * @email 625805189@qq.com
 * @remark
 */
class AlbumFragment: BaseSwipePagerFragment<Album, AlbumViewModel>() {

    override fun showTopBar(): Boolean = true

    override fun isDarkPage(): Boolean = true

    override fun isLazyLoadData(): Boolean = false

    override fun getRootBackgroundColor(): Int = R.color.black

    override fun QMUITopBarLayout.initTopBar() {
        setBackgroundAlpha(0)
    }

    override fun initRecyclerView() {
        super.initRecyclerView()
        getRefreshLayout()?.setMargin(0,QMUIStatusBarHelper.getStatusbarHeight(mActivity),0,0)
    }

    override fun createAdapter(): BaseQuickAdapter<Album, *> = AlbumAdapter()

    override fun onItemClick(adapter: BaseQuickAdapter<*, *>, view: View, position: Int) {
        val images = adapter.data as ArrayList<Album>
        startFragment(AlbumListFragment.newInstance(images,position,getViewModel().page))
    }

    override fun getLayoutManagerType(): LayoutManagerType  = LayoutManagerType.GRID

    override fun getSpanCount(): Int = 3

    override fun getItemSpace(): Int = 2

}